package org.dw.mr;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.euler.commons.web.JsonMapperBuilder;
import com.rrd.dw.mr.gzip.kafka.DHBTagInfoParse;
import com.rrd.dw.utils.DateUtil;
import com.ucredit.babel.common.kafka.PostRecord;
import com.ucredit.babel.common.model.Job;
import com.ucredit.babel.common.model.dhb.DhbItagInfoRecords;

public class DHBtest {
	
	public static void main(String[] args) throws Exception {
		String value=readFile();
		PostRecord postRecord = null;
		DhbItagInfoRecords dhbTagInfoRecords = new DhbItagInfoRecords();
		DHBTagInfoParse dhbTagInfoParse  = new DHBTagInfoParse();
		postRecord = JsonMapperBuilder.build().readValue(value.toString(), PostRecord.class);
		JSONObject jsonObj = JSON.parseObject(value);
		
		String type  = jsonObj.getString("type");
		if (jsonObj.getString("type").equals("DHB_ITAGINFO")) {
			postRecord = JsonMapperBuilder.build().readValue(value.toString(), PostRecord.class);
			
			if (postRecord.getAction().equals("PUT")) {
				
				dhbTagInfoRecords = (DhbItagInfoRecords) postRecord.getRecord();
				
				if (dhbTagInfoRecords != null) {
					Job job = dhbTagInfoRecords.getJob();
					System.out.println(job.getEndTime()==null?"":DateUtil.formateDateStr(job.getEndTime()));
//					dhbTagInfoParse.parseNIFA(null, dhbTagInfoRecords, "");

				}
			}
		}
	}
  public static String readFile() throws IOException{
	  String s="";
	  File file = new File("d:/aa/babel.data");
	  BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "utf-8"));
	  s=br.readLine();
	  System.out.println(s);
	  return s;
  }
}
